/* GUI CONVERTED from remove.p (converter v1.76) Sun Aug 25 20:59:38 2002 */
/* remove.p   - REPETITIVE   MOVE NEXT OPERATION TRANSACTION                  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.23 $                                                               */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 03/29/95   BY: dzn *F0PN*                */
/* REVISION: 8.5      LAST MODIFIED: 05/12/95   BY: pma *J04T*                */
/* REVISION: 8.5      LAST MODIFIED: 11/14/95   BY: ktn *J095*                */
/* REVISION: 8.5      LAST MODIFIED: 02/21/96   BY: jym *G1M9*                */
/* REVISION: 8.5      LAST MODIFIED: 05/16/96   BY: *G1VW* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 06/11/96   BY: aal *K001*                */
/* REVISION: 8.6      LAST MODIFIED: 07/02/96   BY: *G1Z7* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 08/12/96   BY: *J141* Fred Yeadon        */
/* REVISION: 8.6      LAST MODIFIED: 12/31/96   BY: *J1DK* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 05/12/97   BY: *J1R6* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 04/29/98   BY: *H1L0* Dana Tunstall      */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.0      LAST MODIFIED: 12/17/98   BY: *J36Y* G.Latha            */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 09/04/99   BY: *J3KM* G.Latha            */
/* REVISION: 9.1      LAST MODIFIED: 10/25/99   BY: *N002* Bill Gates         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 03/06/00   BY: *N08F* Bill Gates         */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* Revision: 1.21     BY: Robin McCarthy        DATE: 10/17/01  ECO: *P02B*   */
/* Revision: 1.22     BY: Sathish Kumar         DATE: 12/24/01  ECO: *N12R*   */
/* $Revision: 1.23 $       BY: Vivek Gogte           DATE: 08/06/02  ECO: *N1QQ*   */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*V8:ConvertMode=Maintenance                                                 */

{mfdtitle.i "2+ "}

{gldydef.i new}
{gldynrm.i new}

{retrform.i new}
define buffer next_wr_route for wr_route.
define buffer ptmstr for pt_mstr.

define variable batchqty       as   decimal.
define variable comp           as   character.
define variable conv_qty_move  as   decimal.
define variable cumwo_lot      as   character.
define variable rejected       like mfc_logical.
define variable schedwo_lot    as   character.
define variable undo_stat      like mfc_logical no-undo.
define variable trans_type     as   character.
define variable ophist_recid   as   recid.
define variable yn             like mfc_logical.
define variable conv_qty_scrap as   decimal.
define variable last_op        like mfc_logical.
define variable msg_ct         as   integer.
define variable new_conv       like conv.
define variable result_status  as   character   no-undo.
define variable move_to_wkctr  like wc_wkctr    no-undo.
define variable move_to_mch    like wc_mch      no-undo.
define variable trans-ok       like mfc_logical no-undo initial no.

define new shared variable lotserial           like sr_lotser no-undo.
define new shared variable h_wiplottrace_procs as   handle    no-undo.
define new shared variable h_wiplottrace_funcs as   handle    no-undo.

{wlfnc.i} /*FUNCTION FORWARD DECLARATIONS*/
{wlcon.i} /*CONSTANTS DEFINITIONS*/

if is_wiplottrace_enabled()
then do:
   {gprunmo.i &program=""wlpl.p"" &module="AWT"
      &persistent="""persistent set h_wiplottrace_procs"""}
   {gprunmo.i &program=""wlfl.p"" &module="AWT"
      &persistent="""persistent set h_wiplottrace_funcs"""}
end.

/*DEFINE VARIABLES FOR CHANGE ATTRIBUTES FEATURE*/
{gpatrdef.i "new shared"}

eff_date = today.
find first gl_ctrl no-lock.
find first clc_ctrl no-lock no-error.
if not available clc_ctrl
then do:
   {gprun.i ""gpclccrt.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   find first clc_ctrl no-lock.
end.

{gprun.i ""redflt.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

   /*GET EMP, EFFDATE, SHIFT, SITE, CONTROLTOTAL FROM USER*/
   {gprun.i ""retrin1.p"" "(output undo_stat)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if undo_stat
   then
      undo, leave.

   wo-loop:
   repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

      /* TO RESET LOT/SERIAL AFTER COMPLETING THE TRANSACTION */
      /* WHEN AUTO LOT NUMBERS IS SET TO NO IN ITEM MASTER    */
      /* MAINTENANCE                                          */
      lotserial = "".
      /*GET ITEM, OP, LINE FROM USER*/
      {gprun.i ""retrin2.p"" "(output undo_stat)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      if undo_stat
      then
         undo, leave.

      /*FIND REPETITIVE SCHEDULE TO UPDATE*/
      {gprun.i ""reoptr1b.p"" "(input  site,
                                input  line,
                                input  part,
                                input  op,
                                input  eff_date,
                                output routing,
                                output bom_code,
                                output schedwo_lot)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if schedwo_lot = "?"
      then do:
         /* UNEXPLODED SCHEDULE WITH CONSUMPTION PERIOD */
         {pxmsg.i &MSGNUM=325 &ERRORLEVEL=3}
         next-prompt part.
         undo, retry.
      end.

      /*GET BOM, ROUTING FROM USER*/
      {gprun.i ""retrin3.p"" "(output undo_stat)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      if undo_stat
      then
         undo, leave.

      /*FIND CUM ORDER. */
      {gprun.i ""regetwo.p"" "(input  site,
                               input  part,
                               input  eff_date,
                               input  line,
                               input  routing,
                               input  bom_code,
                               output cumwo_lot)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /*VALIDATE THE OPERATION */
      {reopval.i &part    = part
                 &routing = routing
                 &op      = op
                 &date    = eff_date
                 &prompt  = op
                 &frame   = "a"
                 &leave   = ""no""
                 &loop    = "mainloop"
         }

      /* CREATE IT IF IT DOESN'T EXIST*/
      if cumwo_lot = ?
      then do:
         {gprun.i ""recrtwo.p"" "(input  site,
                                  input  part,
                                  input  eff_date,
                                  input  line,
                                  input  routing,
                                  input  bom_code,
                                  output cumwo_lot)"
                                }
/*GUI*/ if global-beam-me-up then undo, leave.


         if cumwo_lot = ? then
            next wo-loop.

         display
            cumwo_lot @ wo_lot
         with frame a.
      end.
      else do:
         display
            cumwo_lot @ wo_lot
         with frame a.

         find wo_mstr where wo_lot = cumwo_lot no-lock.

         if wo_status = "c"
         then do:
            /* CUM ORDER IS CLOSED */
            {pxmsg.i &MSGNUM=5101 &ERRORLEVEL=3}
            undo, retry.
         end.
      end.

      find wr_route
         where wr_lot = cumwo_lot
           and wr_op  = op no-lock no-error.
      if not available wr_route
      then do:
         /* OPERATION DOES NOT EXIST */
         {pxmsg.i &MSGNUM=106 &ERRORLEVEL=3}
         next-prompt op with frame a.
         undo, retry.
      end.

      if not wr_milestone
      then do:
         /* OPERATION NOT A MILESTONE */
         {pxmsg.i &MSGNUM=560 &ERRORLEVEL=2}

         if is_wiplottrace_enabled()
         then do:
            if prev_milestone_operation(cumwo_lot, op) <> ?
               and is_operation_queue_lot_controlled
               (cumwo_lot, prev_milestone_operation(cumwo_lot, op),
               OUTPUT_QUEUE)
            then do:
               /*WIP LOT TRACE IS ENABLED AND OPERATION IS A NON-MILESTONE*/
               {pxmsg.i &MSGNUM=8465 &ERRORLEVEL=3}
               undo, retry.
            end.
         end.
      end.

      find first wr_route
         where wr_lot = cumwo_lot
           and wr_op  > op
         no-lock no-error.

      last_op = not available wr_route.
      find wr_route
         where wr_lot = cumwo_lot
           and wr_op  = op
         no-lock no-error.

      display
         wr_desc
      with frame a.

      assign
         wkctr     = ""
         mch       = ""
         dept      = ""
         qty_move  = 0
         um        = ""
         conv      = 1
         mod_issrc = no.

      {gprun.i ""resetmno.p"" "(input  cumwo_lot,
                                input  op,
                                output move_next_op)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      assign
         wkctr = wr_wkctr
         mch   = wr_mch.
      find wc_mstr
         where wc_wkctr = wkctr
           and wc_mch   = mch no-lock.

      dept = wc_dept.
      find dpt_mstr where dpt_dept = wc_dept no-lock no-error.

      find wo_mstr where wo_lot = cumwo_lot no-lock.
      find pt_mstr where pt_part = wo_part no-lock.
      um = pt_um.

      find first ea_mstr no-lock where ea_type = "1" no-error.
      if available ea_mstr
      then
         earn_code = ea_earn.

      display
         wkctr
         mch
         wc_desc
         dept
         dpt_desc          when (available dpt_mstr)
         ""                when (not available dpt_mstr) @ dpt_desc
         um
         conv
         qty_move
         mod_issrc         when (last_op)
         ""                when (not last_op) @ mod_issrc
      with frame move1.

      if is_wiplottrace_enabled()
      then do:
         run init_move_wip_lot_temptable in h_wiplottrace_procs.
      end.

      /* LOOPC ADDED TO BRING THE CURSOR CONTROL TO SECOND         */
      /* FRAME DURING UNDO,RETRY                                   */

      loopc:
      do with frame move1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


         for each sr_wkfl exclusive-lock where sr_userid = mfguser:
            delete sr_wkfl.
         end.

         for each pk_det exclusive-lock where pk_user = mfguser:
            delete pk_det.
         end.

         /*DELETE LOTW_WKFL*/
         {gprun.i ""gplotwdl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


         do with frame move1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

            {regetwcm.i &framename=move1}

            do with frame move1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

               set
                  dept
                  um
                  conv
                  qty_move
                  mod_issrc when (last_op)
               editing:
                  if frame-field = "dept"
                  then do:
                     {mfnp05.i dpt_mstr dpt_dept yes dpt_dept
                        "input frame move1 dept"}

                     if recno <> ?
                     then
                        display
                           dpt_dept @ dept dpt_desc.
                  end.
                  else do:
                     ststatus = stline[3].
                     status input ststatus.
                     readkey.
                     apply lastkey.
                  end.
               end.

               find dpt_mstr where dpt_dept = dept no-lock no-error.

               if not available dpt_mstr
               then do:
                  next-prompt dept.
                  /* DEPARTMENT DOES NOT EXIST */
                  {pxmsg.i &MSGNUM=532 &ERRORLEVEL=3}
                  undo, retry.
               end.

               display dpt_desc.

               find pt_mstr where pt_part = part no-lock.

               if um <> pt_um
               then do:
                  {gprun.i ""gpumcnv.p"" "(input  um,
                                           input  pt_um,
                                           input  part,
                                           output new_conv)"
                     }
/*GUI*/ if global-beam-me-up then undo, leave.


                  if new_conv = ?
                  then do:
                     /* NO UNIT OF MEASURE CONVERSION EXISTS */
                     {pxmsg.i &MSGNUM=33 &ERRORLEVEL=2}
                  end.
                  else do:
                     if not frame move1 conv entered
                     then do:
                        conv = new_conv.
                        display conv.
                     end.
                  end.
               end.
            end.
/*GUI*/ if global-beam-me-up then undo, leave.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         conv_qty_move = qty_move * conv.

         /*CHECK QUEUES IF WOULD GO NEGATIVE; IF SO ISSUE MESSAGES*/
         msg_ct = 0.

         /*CHECK OUTPUT QUEUE*/
         {gprun.i ""rechkq.p"" "(input        cumwo_lot,
                                 input        op,
                                 input        ""o"",
                                 input        (- conv_qty_move),
                                 input-output msg_ct)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         /*CHECK INPUT QUEUE NEXT OPERATION*/
         find first wr_route
            where wr_lot = cumwo_lot
              and wr_op  > op
            no-lock no-error.

         if available wr_route then do:
            {gprun.i ""rechkq.p"" "(input cumwo_lot, input wr_op,
                 input ""i"",
                 input conv_qty_move,
                 input-output msg_ct)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end.

         /*FORCE A PAUSE IF NECESSARY*/
         {gprun.i ""repause.p"" "(input msg_ct)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if is_wiplottrace_enabled()
            and is_operation_queue_lot_controlled(cumwo_lot, op,
            OUTPUT_QUEUE)
         then do:
            if is_last_operation(cumwo_lot, op)
            then do:
               mod_issrc = true.
               lotserial = ''.
               /*ENTER WIP LOTS TO MOVE IN RECEIPT DATA INPUT FRAME*/
               {pxmsg.i &MSGNUM=8464 &ERRORLEVEL=1}
            end.
            else do:
               run get_destination_wkctr_mch_from_user
                  in h_wiplottrace_procs
                  (input  cumwo_lot,
                   input  next_milestone_operation(cumwo_lot, op),
                   output move_to_wkctr,
                   output move_to_mch,
                   output undo_stat).

               if undo_stat then
                  undo, retry.

               run get_move_wip_lots_from_user
                  in h_wiplottrace_procs
                  (input  cumwo_lot,
                   input  op,
                   input  qty_move,
                   input  conv,
                   input  um,
                   input  site,
                   input  wkctr,
                   input  mch,
                   input  move_to_wkctr,
                   input  move_to_mch,
                   output undo_stat).

               if undo_stat then
                  undo, retry.
            end.
         end.

         /*FORCE MODIFY FINISHED PART RECEIVE LIST IF AT LAST OP AND
         L/S CONTROLLED, OR IF FOR SOME REASON NOT RECEIVABLE*/
         if conv_qty_move <> 0 and
            last_op
         then do:
            find wo_mstr where wo_lot = cumwo_lot no-lock.
            find pt_mstr where pt_part = wo_part no-lock.
            rejected = no.

            if index("LS",pt_lot_ser) = 0
            then do:
               {gprun.i ""icedit2.p""
                  "(input  ""RCT-WO"",
                    input  if wo_site > """" then wo_site
                           else pt_site,
                    input  if wo_loc > """" then wo_loc
                           else pt_loc,
                    input  wo_part,
                    input  """",
                    input  """",
                    input  conv_qty_move,
                    input  pt_um,
                    input  """",
                    input  """",
                    output rejected)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end.

            if index("LS",pt_lot_ser) > 0 or
               mod_issrc or
               rejected
            then do:
               hide frame move1 no-pause.
               hide frame a no-pause.

               display
                  site
                  part
                  op
                  line
               with frame b side-labels width 80 attr-space.

               /*MODIFY FINISHED PART RECEIVE LIST*/
               {gprun.i ""rercvlst.p"" "(input  cumwo_lot,
                                         input  conv_qty_move,
                                         output undo_stat)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               hide frame b no-pause.

               if undo_stat
               then do:
                  view frame a.
                  view frame move1.

                  if batchrun
                  then
                     undo mainloop, leave mainloop.
                  else
                     undo, retry.
               end.

               if is_wiplottrace_enabled()
                  and is_operation_queue_lot_controlled
                  (cumwo_lot, op, OUTPUT_QUEUE)
               then do:
                  run move_check_wip_lots
                     (input  cumwo_lot,
                      input  op,
                      input  wkctr,
                      input  mch,
                      output result_status).

                  if result_status = FAILED_EDIT
                  then
                     undo, retry.
               end.
            end.
            else do:
               do transaction:
                  create sr_wkfl.
                  assign
                     sr_userid = mfguser
                     sr_lineid = "+" + wo_part
                     sr_site   = wo_site
                     sr_loc    = wo_loc
                     sr_qty    = conv_qty_move.

                  if sr_loc = ""
                  then
                     sr_loc = pt_loc.

                  /* MOVED RESTRICTED TRANSACTION VALIDATION FROM */
                  /* icedit FILES TO worcat01.p FOR "RCT-WO"      */
                  /* TRANSACTIONS.WHEN LOT/SERIAL  = "" IN ITEM   */
                  /* MASTER MAINTENANCE,ITEM WILL NOW BE RECEIVED */
                  /* WITH THE RESPECTIVE VALID STATUS             */
                  /* CHANGE ATTRIBUTES.INITIALIZE ATTRIBUTE       */
                  /* VARIABLES WITH CURRENT SETTINGS              */
                  assign
                     chg_assay   = wo_assay
                     chg_grade   = wo_grade
                     chg_expire  = wo_expire
                     chg_status  = wo_rctstat
                     assay_actv  = yes
                     grade_actv  = yes
                     expire_actv = yes
                     status_actv = yes.

                  if wo_rctstat_active = no
                  then do:
                     for first in_mstr
                        fields(in_part in_site
                        in_rctwo_active in_rctwo_status)
                        no-lock
                        where in_part = wo_part
                          and in_site = wo_site:
                     end. /* FOR FIRST in_mstr */
                     if available in_mstr and
                        in_rctwo_active = yes
                     then
                        chg_status = in_rctwo_status.
                     else
                        if available pt_mstr and
                           pt_rctwo_active
                        then
                           chg_status = pt_rctwo_status.
                        else do:
                           assign
                              chg_status  = ""
                              status_actv = no.
                        end. /* ELSE DO */
                  end. /* IF wo_rctstat_active = NO */

                  /* TO CHECK WHETHER "RCT-WO" IS RESTRICTED */
                  /* FOR RECEIVING INVENTORY STATUS.ALSO TO  */
                  /* CHECK FOR STATUS CONFLICT MESSAGE       */
                  {gprun.i ""worcat01.p""
                     "(input recid(wo_mstr),
                       input sr_site,
                       input sr_loc,
                       input sr_ref,
                       input sr_lotser,
                       input eff_date,
                       input sr_qty,
                       input-output chg_assay,
                       input-output chg_grade,
                       input-output chg_expire,
                       input-output chg_status,
                       input-output assay_actv,
                       input-output grade_actv,
                       input-output expire_actv,
                       input-output status_actv,
                       output trans-ok)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if not trans-ok
                  then do:
                     next-prompt qty_move.
                     undo loopc,retry loopc.
                  end. /* IF NOT trans-ok */

               end.
            end.
         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         view frame a.
         view frame move1.

         yn = yes.
         /* PLEASE CONFIRM UPDATE */
         {pxmsg.i &MSGNUM=32 &ERRORLEVEL=1 &CONFIRM=yn}
         if yn <> yes
         then
            undo, retry.
      end.
/*GUI*/ if global-beam-me-up then undo, leave.


      /*************************************/
      /*  GOT ALL DATA AND VALIDATED IT,   */
      /*  NOW WE CAN DO SOMETHING WITH IT  */
      /*************************************/

      /*NO TRANSACTION SHOULD BE PENDING HERE*/
      {gprun.i ""gpistran.p"" "(input 1, input """")"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if conv_qty_move <> 0
      then do:
         trans_type = "MOVE".

         {gprun.i ""reophist.p"" "(input  trans_type,
                                   input  cumwo_lot,
                                   input  op,
                                   input  emp,
                                   input  wkctr,
                                   input  mch,
                                   input  dept,
                                   input  shift,
                                   input  eff_date,
                                   output ophist_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         find first wr_route
            where wr_lot = cumwo_lot
              and wr_op  > op
            no-lock no-error.
         if available wr_route
         then do:
            do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.

               {gprun.i ""removea.p"" "(input cumwo_lot,
                                        input op,
                                        input eff_date,
                                        input ophist_recid,
                                        input conv_qty_move)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               /*MOVE LIST OF INPUT WIP LOTS AND OUTPUT WIP LOTS*/

               if is_wiplottrace_enabled()
                  and is_operation_queue_lot_controlled(cumwo_lot, op,
                  OUTPUT_QUEUE)
               then do:
                  run move_move_wip_lots
                     in h_wiplottrace_procs
                     (cumwo_lot, op, conv, site, wkctr, mch,
                     move_to_wkctr, move_to_mch).
               end.
            end.
/*GUI*/ if global-beam-me-up then undo, leave.

         end.
         else do:
            /* RECEIVE COMPLETED MATERIAL */

            /* DETERMINE IF WAREHOUSING INTERFACE IS ACTIVE */
            if can-find(first whl_mstr no-lock
               where whl_act = true)
            then do:

               for each sr_wkfl where sr_userid = mfguser no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


                  /* CREATE AN EXPORT TRANSACTION FOR THE REPETITIVE RECEIPT */
                  {gprun.i ""wireoptr.p""
                     "(input 'wi-remove',
                       input wkctr,
                       input sr_qty,
                       input sr_site,
                       input sr_loc,
                       input eff_date,
                       input shift,
                       input wo_part,
                       input sr_lotser,
                       input sr_ref,
                       input um,
                       input conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               end.
/*GUI*/ if global-beam-me-up then undo, leave.


            end.

            /*THIS SUBPROGRAM PICKS UP INPUT FROM SR_WKFL            */
            {gprun.i ""receive.p"" "(input cumwo_lot,
                                     input eff_date,
                                     input ophist_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            {gprun.i ""gplotwdl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


            if clc_lotlevel <> 0 and
               pt_lot_ser = "L"
            then
            do transaction:
               find wo_mstr where wo_lot = cumwo_lot exclusive-lock.
               if available wo_mstr and
                  not wo_lot_rcpt
               then
                  wo_lot_next = "".
            end.
         end.
      end.

      for each sr_wkfl exclusive-lock where sr_userid = mfguser:
         delete sr_wkfl.
      end.

      for each pk_det exclusive-lock where pk_user = mfguser:
         delete pk_det.
      end.

      global_addr = string(ophist_recid).
      {gprun.i ""reintchk.p"" "(input cumwo_lot)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   end.
/*GUI*/ if global-beam-me-up then undo, leave.

end.

if is_wiplottrace_enabled()
then
   delete PROCEDURE h_wiplottrace_procs no-error.

if is_wiplottrace_enabled()
then
   delete PROCEDURE h_wiplottrace_funcs no-error.

PROCEDURE move_check_wip_lots:
   define input parameter ip_wo_id          as   character no-undo.
   define input parameter ip_wo_op          as   integer   no-undo.
   define input parameter ip_wkctr          like wc_wkctr  no-undo.
   define input parameter ip_mch            like wc_mch    no-undo.
   define output parameter op_result_status as   character no-undo.

   define variable result_status as character no-undo.
   define variable msgno         as integer   no-undo.
   define variable msgtxt        as character no-undo.

   for first wo_mstr where wo_lot = ip_wo_id no-lock:
   end.

   for each sr_wkfl no-lock
      where sr_userid = mfguser
        and sr_lineid begins '+':
/*GUI*/ if global-beam-me-up then undo, leave.


      /* ADD 12th (msgno) AND 13th(msgtxt) PARAMETER */
      run check_change_wip_qty_alloc_qoh in h_wiplottrace_procs
         (input ip_wo_id,
          input ip_wo_op,
          input sr_lotser,
          input sr_ref,
          input wo_site,
          input ip_wkctr,
          input ip_mch,
          input OUTPUT_QUEUE,
          input ip_wo_id,
          input ip_wo_op,
          input - sr_qty,
          output msgno,
          output msgtxt,
          output result_status).

      if result_status = FAILED_EDIT
      then do:
         {pxmsg.i &MSGNUM=msgno &ERRORLEVEL=3 &MSGARG1=msgtxt}
         op_result_status = FAILED_EDIT.
      end.
      else
      if result_status = PASSED_EDIT
         and msgno    <> 0
      then do:
         {pxmsg.i &MSGNUM=msgno &ERRORLEVEL=2 &MSGARG1=msgtxt}
      end.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.

END PROCEDURE.
